Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Imaging with QuickDraw

Previous | Chapter Top | Chapter Contents | Next |

Saving and Restoring Graphics Ports and Offscreen Graphics Worlds

To save the current graphics port (basic, color, or offscreen) and the current GDevice record, use the GetGWorld procedure. To change the current graphics port (basic, color, or offscreen), use the SetGWorld procedure; any drawing your application performs then occurs in this graphics port.

You can use the GetGWorldDevice function to obtain a handle to the GDevice record associated with an offscreen graphics world.

GetGWorld

To save the current graphics port (basic, color, or offscreen) and the current GDevice record, use the GetGWorld procedure.

PROCEDURE GetGWorld (VAR port: CGrafPtr; VAR gdh: GDHandle);
port
A pointer to an offscreen graphics world, color graphics port, or basic graphics port, depending on which is the current port.
gdh
A handle to the GDevice record for the current device.

DESCRIPTION

The GetGWorld procedure returns a pointer to the current graphics port in the port parameter. This parameter can return values of type GrafPtr , CGrafPtr , or GWorldPtr , depending on whether the current graphics port is a basic graphics port, color graphics port, or offscreen graphics world. The GetGWorld procedure returns a handle to the GDevice record for the current device in the gdh parameter.

After using GetGWorld to save a graphics port and a GDevice record, your application can later use the SetGWorld procedure, described next, to restore them.

SPECIAL CONSIDERATIONS

The GetGWorld procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the GetGWorld procedure are

Trap macro

Selector

_QDExtensions

$00080005

SEE ALSO

Listing 6-1 and Listing 6-2 illustrate how to use the GetGWorld  procedure to save the current graphics port for an active window, the  SetGWorld procedure to change the current graphics port to an offscreen graphics world, and then SetGWorld again to restore the active window as the current graphics port.

SetGWorld

To change the current graphics port (basic, color, or offscreen), use the SetGWorld procedure.

PROCEDURE SetGWorld (port: CGrafPtr; gdh: GDHandle);
port
A pointer to an offscreen graphics world, color graphics port, or basic graphics port.
gdh
A handle to a GDevice record. If you pass a pointer to an offscreen graphics world in the port parameter, set this parameter to NIL , because SetGWorld ignores this parameter and sets the current device to the device attached to the offscreen graphics world.

DESCRIPTION

The SetGWorld procedure sets the current graphics port to the one specified by the port parameter and--unless you set the current graphics port to be an offscreen graphics world--sets the current device to that specified by the gdh parameter.

In the port parameter, you can specify values of type GrafPtr , CGrafPtr , or GWorldPtr , depending on whether you want to set the current graphics port to be a basic graphics port, color graphics port, or offscreen graphics world. Any drawing your application performs then occurs in this graphics port.

SPECIAL CONSIDERATIONS

The SetGWorld procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the SetGWorld procedure are

Trap macro

Selector

_QDExtensions

$00080006

SEE ALSO

Listing 6-1 and Listing 6-2 illustrate how to use the GetGWorld  procedure to save the current graphics port for an active window, the  SetGWorld procedure to change the current graphics port to an offscreen graphics world, and then SetGWorld again to restore the active window as the current graphics port.

GetGWorldDevice

Use the GetGWorldDevice function to obtain a handle to the GDevice record associated with an offscreen graphics world.

FUNCTION GetGWorldDevice (offscreenGWorld: GWorldPtr): GDHandle;
offscreenGWorld
A pointer to an offscreen graphics world. The pointer returned to your application by the NewGWorld function.

DESCRIPTION

The GetGWorldDevice function returns a handle to the GDevice record associated with the offscreen graphics world specified by the offscreenGWorld parameter. In this parameter, supply the pointer returned to your application by the NewGWorld function when you created the offscreen graphics world. If you created the offscreen world by specifying the noNewDevice flag, the GDevice record is for one of the screen devices or is the GDevice record that you specified to NewGWorld or UpdateGWorld .

Note: QuickTime 3 for Windows does not support the noNewDevice flag.

If you point to a GrafPort or CGrafPort record in the offscreenGWorld parameter, GetGWorldDevice returns the current device.

SPECIAL CONSIDERATIONS

The GetGWorldDevice function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.

ASSEMBLY-LANGUAGE INFORMATION

The trap macro and routine selector for the GetGWorldDevice function are

Trap macro

Selector

_QDExtensions

$00040012


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next